%script to test the methods implemented and calculate distances between the
%optimized paramemeters and the known optimums parameters in a trainig set

clear all;
close all;

%DEBUG: optimum values
 Ps = [3 3;1 2;5 6;2 6;2 2];
 Ws = [34.59; 7.556; 4.2476; 19.717; 29.217; 34.805];

distp = zeros(10,1);
distw = zeros(10,1);
costs = zeros(10,1);

%Y Target Variable
Y = csvread('Data\TestData\Y.csv');

%X rawdata training data set
X = csvread('Data\TestData\X.csv');

%feature scaling to avoid overflow
[X, mu, st] = featureScaling(X);

for i=1:10
    
tic;
    [Poptim PCostO Woptim WCostO Coptim] = approach1(Y, X, 400, 0.1, 1);
    costs(i,1) = Coptim;
   
    %[Woptim, Coptim] = approach2(Y, X, 7, 400, 0.1, 1);
    %costs(i,1) = Coptim(end,1);
toc     
    distp(i,1) = sqrt(sum((Ps(:) - Poptim(:)).^ 2));
    distw(i,1) = sqrt(sum((Ws(:) - Woptim(:)).^ 2));
    
end;

%DEBUG:
sprintf('mean dist to p*: %.2f', mean(distp))
sprintf('std dist to p*: %0.2f', std(distp))
sprintf('mean dist to w*: %.2f', mean(distw))
sprintf('std dist to w*: %0.2f', std(distw))
sprintf('mean training cost: %0.2f', mean(costs))
sprintf('std training cost: %0.2f', std(costs))


figure,plot(PCostO);
figure,plot(WCostO);
